// 内容
axios({
  method: 'get',
  url: 'http://cba.itlike.com/public/index.php?s=/api/page/detail'
}).then(({ data }) => {
  console.log(data.data.pageData.items[6].data)
  let arr = data.data.pageData.items[6].data
  const box1 = document.querySelector('.box1')
  let str = ''
  arr.forEach(ele => {
    // console.log(ele)
    if (ele.line_price_max === '0.00') {
      str += `
      <div class="phone">
      <a href="#">
        <div class="left">
          <img src="${ele.goods_image}" alt="" />
        </div>
        <div class="right">
          <span class="ellipsis-2"
            >${ele.goods_name}
          </span>
          <p>已售${ele.goods_sales}件</p>
          <div class="yi">
            <em>¥${ele.goods_price_max}</em>
            <span></span>
          </div>
        </div>
      </a>
    </div>
        `
    } else {
      str += `
      <div class="phone">
      <a href="#">
        <div class="left">
          <img src="${ele.goods_image}" alt="" />
        </div>
        <div class="right">
          <span class="ellipsis-2"
            >${ele.goods_name}
          </span>
          <p>已售${ele.goods_sales}件</p>
          <div class="yi">
            <em>¥${ele.goods_price_max}</em>
            <span>¥${ele.line_price_max}</span>
          </div>
        </div>
      </a>
    </div>
    `
    }
  })
  box1.innerHTML = str
})

// 商品列表
// /cart/list
// axios.defaults.baseURL = 'http://cba.itlike.com/public/index.php?s=/api/'
axios({
  method: 'get',
  url: 'http://cba.itlike.com/public/index.php?s=/api/page/detail'
}).then(({ data: res }) => {
  // console.log(res.data.pageData.items[3])
  let arr = res.data.pageData.items[3].data
  let str1 = ''
  arr.forEach(function (ele, index) {
    str1 += `
    <a href="#">
    <span
      ><img
        src="${ele.imgUrl}"
        alt=""
      />
      <p>新品首发</p>
    </span>
  </a>
    `
  })
  document.querySelector('.big').innerHTML = str1
})

// 轮播图
axios({
  method: 'get',
  url: 'http://cba.itlike.com/public/index.php?s=/api/page/detail'
}).then(data => {
  console.log(data.data.data.pageData.items[1])
  let lun = data.data.data.pageData.items[1].data
  let lunbo = ''
  lun.forEach(function (ele, index) {
    lunbo += `
    <div class="swiper-slide">
      <a href="#"> <img src="${ele.imgUrl}" alt="" /></a>
    </div>
    
    `
  })
  document.querySelector('.swiper-wrapper').innerHTML = lunbo
})
// 小标题
axios({
  method: 'get',
  url: 'http://cba.itlike.com/public/index.php?s=/api/page/detail'
}).then(data => {
  console.log(data.data.data.pageData.items[4].data)
  let biaoTi = data.data.data.pageData.items[4].data
  let str3 = ''
  biaoTi.forEach(ele => {
    str3 += `
   
    <img src="${ele.imgUrl}" alt="" />

    `
  })
  document.querySelector('.venue').innerHTML = str3
})
